<template>
    <div class="container">
        <el-form :model="ruleForm" ref="ruleForm" :rules="rules"  label-width="180px" class="demo-ruleForm">
            <el-row  style="margin-top:20px;">
                <el-col :span="12">
                    <el-form-item label="申请人姓名：" prop="name">
            			{{ruleForm.name}}

                    </el-form-item>
                    <el-form-item label="申请人身份证号：" prop="idCard">
            			{{ruleForm.idCard}}

                    </el-form-item>
                    <el-form-item label="还款周期：" prop="loanPeriod">
            			{{ruleForm.loanPeriod}}

                    </el-form-item>
                </el-col>
                <el-col :span="10">
                    <el-form-item label="申请用途：" prop="remarks">
            			{{ruleForm.remarks}}

                    </el-form-item>
                    <el-form-item label="申请贷款金额：" prop="amount">
            			{{ruleForm.amount}}

                    </el-form-item>

                </el-col>
            </el-row>
            <el-row>
            	<el-col :span="12">
            		<el-form-item label="身份证照片：（人像面）" >
            		     <img :src="$store.state.plantImg + ruleForm.idCardJustImg" alt="" class="imgas">
            		</el-form-item>
            		<el-form-item label="身份证照片：（国徽面）"  >
            		    <img :src="$store.state.plantImg + ruleForm.idCardBackImg" alt="" class="imgas">
            		</el-form-item>
            		<el-form-item label="担保公司名称：" prop="guaranteeCompanyName">
            			{{ruleForm.guaranteeCompanyName}}

            		</el-form-item>
            		<el-form-item label="担保公司法人名称：" prop="guaranteeCompanyLegalPerson">
            			{{ruleForm.guaranteeCompanyLegalPerson}}

            		</el-form-item>
            		<el-form-item label="联系人：" prop="contactsPeople">
            			{{ruleForm.contactsPeople}}

            		</el-form-item>
            		<el-form-item label="营业执照："  >
            		      <img :src="$store.state.plantImg + ruleForm.businessImg" alt="" class="imgas">
            		</el-form-item>
            		<el-form-item label="资质认定书："  >
            		      <img :src="$store.state.plantImg + ruleForm.naturalImg" alt="" class="imgas">
            		</el-form-item>
            	</el-col>
            	<el-col :span="10">
            		<el-form-item label="股权架构明细：">
            		    <img :src="$store.state.plantImg + ruleForm.sharesImg" alt="" class="imgas">
            		</el-form-item>
            		<el-form-item label="贷款申请书：">
            		      <img :src="$store.state.plantImg + ruleForm.applyImg" alt="" class="imgas">
            		</el-form-item>
            		<el-form-item label="担保公司法人身份证号：" prop="guaranteeCompanyLegalPersonIdCard">
            			{{ruleForm.guaranteeCompanyLegalPersonIdCard}}

            		</el-form-item>
            		<el-form-item label="组织代码：" prop="businessLicenseNum">
            			{{ruleForm.businessLicenseNum}}

            		</el-form-item>
            		<el-form-item label="联系人电话：" prop="contactsTel">
            			{{ruleForm.contactsTel}}

            		</el-form-item>
            	</el-col>
            </el-row>
            <el-row>
            	<el-col :span="12">
            		<el-form-item label="抵押品：" prop="mortgage">
            			{{ruleForm.mortgage}}

            		</el-form-item>
            	</el-col>
            	<el-col :span="10">
            		<el-form-item label="抵押品估值：" prop="mortgageValue">
            			{{ruleForm.mortgageValue}}

            		</el-form-item>
            	</el-col>
            </el-row>
            <el-row v-if="ruleForm.mortgage == '土地证'">
            	<el-col :span="12">
            		<el-form-item label="土地使用权人：" prop="legalPerson">
            			{{ruleForm.legalPerson}}

            		</el-form-item>
            		<el-form-item label="座落：" prop="position">
            			{{ruleForm.position}}

            		</el-form-item>
            		<el-form-item label="地号：" prop="landNum">
            			{{ruleForm.landNum}}

            		</el-form-item>
            		<el-form-item label="上传土地证："  >
            		     <img :src="$store.state.plantImg + ruleForm.proveImg" alt="" class="imgas">
            		</el-form-item>
            	</el-col>
            	<el-col :span ="10">
            		<el-form-item label="地类（用途）：" prop="purpose">
            			{{ruleForm.purpose}}

            		</el-form-item>
            		<el-form-item label="使用权类型：" prop="usufruct">
            			{{ruleForm.usufruct}}

            		</el-form-item>
            		<el-form-item label="使用权面积：" prop="area">
            			{{ruleForm.area}}

            		</el-form-item>
            	</el-col>
            </el-row>
            <el-row v-if="ruleForm.mortgage == '林权证'">
            	<el-col :span="12">
            		<el-form-item label="所有权权利人：" prop="legalPerson">
            			{{ruleForm.legalPerson}}

            		</el-form-item>
            		<el-form-item label="座落：" prop="position">
            			{{ruleForm.position}}

            		</el-form-item>
            		<el-form-item label="林地使用期：" prop="term">
            			{{ruleForm.term}}

            		</el-form-item>
            		<el-form-item label="上传林权证："  >
            		     <img :src="$store.state.plantImg + ruleForm.proveImg" alt="" class="imgas">
            		</el-form-item>
            	</el-col>
            	<el-col :span ="10">
            		<el-form-item label="面积：" prop="area">
            			{{ruleForm.area}}

            		</el-form-item>
            		<el-form-item label="林种：" prop="species">
            			{{ruleForm.species}}

            		</el-form-item>

            	</el-col>
            </el-row>
			<el-row>
				<el-col :span="12">
					<!-- <el-form-item label="放款时间：" prop="species">
					    <el-input placeholder="请输入内容" v-model="data.species" style="width: 300px"></el-input>
					</el-form-item> -->
					<el-form-item label="贷款利率：" prop="rate">
					    <el-input placeholder="请输入内容" v-model="data1.rate" style="width: 300px"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span ="10">
					<el-form-item label="每期应还：" prop="monthlyAmount">
					    <el-input placeholder="请输入内容" v-model="data1.amount" style="width: 300px"></el-input>
					</el-form-item>
				</el-col>
			</el-row>
			<el-row>
			    <el-form-item label="备注：">
			        <textarea name="" id="" cols="121" rows="5" style="border:1px solid #cccccc;" v-model="data1.remarks"></textarea>
			    </el-form-item>
			</el-row>
            <el-form-item class="footerFixed" label-width="0px">
                <el-button type="primary" @click="submitrule('ruleForm')">通过</el-button>
				<el-button @click="refuse">拒绝</el-button>
                <el-button @click="backPage">返回</el-button>
            </el-form-item>

        </el-form>
    </div>
</template>

<script>
import axios from "axios"
import uploadImg from '../../../common/uploadImg';
export default {
	components: {
	    uploadImg
	},
    data() {
        return {
			data1:{},
			amount:{},
			backname:{},
			bankShow:false,
			bankList:[],
            listUrl1:'',
            ruleForm: {
				status:0,
                files: '',
				mortgage:'林权证',
            },
			list:[{name:'土地证'},{name:'林权证'}],
			subBank:[],
            rules: {

            },
			id:''
        };
    },
    mounted() {
		this.id = this.$route.query.id
        this.init();

    },
    methods: {
		// 根据银行获取支行
        getbank(e){
			// console.log(e)
			this.backname = ""
			this.bankShow = true
			this.ruleForm.pid = e.id
			this.ruleForm.bankName = e.name
			this.subBank = e.bankInfo
		},
		// 获取支行信息
		getbankname(e){
			console.log(e)
			this.ruleForm.branchBankName = e.name
			this.ruleForm.bankInfoId = e.id
		},
		// 返回上一页
        backPage() {
            this.$router.go(-1);
        },
		// 获取详情
        init(){

			axios.get("http://grove.cpzsyun.com:81/api/control/loanInfo/findById/"+this.id).then((res)=>{
				this.ruleForm = res.data

			})
		},
		// 通过
		submitrule(){
			this.$confirm('是否确认通过审核', '提示', {
			    confirmButtonText: '确定',
			    cancelButtonText: '取消',
			    type: 'warning'
			}).then(() => {
				// let id = this.id + "/1"
				let value= {
					id:this.id,
					status:1,
					rate:this.data1.rate,
					amount:this.data1.amount
				}
				axios.post("http://grove.cpzsyun.com:81/api/control/loanInfo/applyStatus",value).then((res)=>{
					let data = this.data1
					data.loanPeriod = this.ruleForm.loanPeriod
					data.loanId = this.id
					data.bankInfoId = this.ruleForm.bankInfoId
					data.companyId = this.ruleForm.companyId
					data.name = this.ruleForm.name

					axios.post("http://grove.cpzsyun.com:81/api/control/repayment/pay",data).then(res=>{
						this.$notify({
						    title: '提示',
						    message: '保存成功',
						    type: 'success',
						    duration: 1000
						});
						this.backPage()
					})
				})
			})
		},
		// 拒绝
		refuse(){
			this.$confirm('是否确认拒绝审核', '提示', {
			    confirmButtonText: '确定',
			    cancelButtonText: '取消',
			    type: 'warning'
			}).then(() => {
				let id = this.id + "/-1"
				let value= {
					id:this.id,
					status:-1,

				}
				axios.post("http://grove.cpzsyun.com:81/api/control/loanInfo/applyStatus",value).then((res)=>{
					let data = this.data1
					data.loanPeriod = this.ruleForm.loanPeriod
					data.loanId = this.id
					data.bankInfoId = this.ruleForm.bankInfoId
					data.companyId = this.ruleForm.companyId
					data.name = this.ruleForm.name
					this.backPage()

				})
			})
		}

    }
};
</script>

<style scoped>
.avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    width: 180px;
    overflow: hidden;
}

.avatar-uploader .el-upload:hover {
    border-color: #409EFF;
}
.el-upload--text {
    width: 180px;
}
.avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
}
.avatar {
    width: 178px;
    height: 178px;
    display: block;
}
.imgas{
	width: 200px;
	height:200px;
}
</style>
